<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<!-- <meta http-equiv="refresh" content="2" /> -->
	<title>自定义个人个性头像</title>
	<!--[if lt IE 9]>
		<script src="<%=basePath %>js/ie9.js"></script>
	<![endif]-->
	<link rel="icon" href="<%=basePath %>images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="<%=basePath %>images/favicon.ico" type="image/x-icon" />
	<script src="<%=basePath %>js/jquery-1.4.2.min.js"></script>
	<script src="<%=basePath %>js/sign-up.js"></script>
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/signup.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/upload.sticker.css" />
	<link type="text/css" rel="stylesheet" href="<%=basePath %>css/uploadify.css"/>
  	<link type="text/css" rel="stylesheet" href="<%=basePath %>css/jquery.Jcrop.css"/>
	<script type="text/javascript" src="<%=basePath %>js/jquery.uploadify.v2.1.4.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/jquery.Jcrop.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/swfobject.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/jQuery.UtrialAvatarCutter.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/upload.sticker.js"></script>
	<script type="text/javascript">
	$(function() {
		var maxWidth = 300;  
	    var maxHeight = 300;
	    var curWidth  = $("#big img").width();  
	    var curHeight = $("#big img").height();  
	    if(curWidth > maxWidth){  
	         $("#big img").width(maxWidth);  
	    }  
	    if(curHeight > maxHeight){
	         $("#big img").height(maxHeight);  
	    }
	});
	</script>
	<style type="text/css">
		#preview{float:left;margin-right:10px;}
	</style>
</head>
<body>
<c:if test="${sessionScope.loginUser == null}">
	<script type="text/javascript">
		window.location.href = "../jsp/login.jsp";
	</script>
</c:if>
<c:if test="${sessionScope.loginUser != null}">
	<div id="header">
		<div class="header-content">
			<h1 class="logo">
				<a href="<%=basePath %>jsp/index.jsp">sharelife</a>
			</h1>
			<a href="<%=basePath %>jsp/upload.jsp" class="nav-upload">上传</a>
			<form action="pictureAction!findByKeyWord" class="search" method="post">
				<div class="search-group">
					<input type="text" name="keyWord" class="field style" value="用户名、图片类别"/>
					<input type="hidden" name="page" value="1"/>
					<input type="submit" title="Submit" value="" class="submit" />
				</div>
			</form>
			<div class="login">
				<img src="<%=basePath %>${sessionScope.loginUser.photoSticker}" width="30" height="30"/>
				<a href="#">${sessionScope.loginUser.userName }</a>
			</div>
		</div>
	</div> <!-- header -->
	<form action="" class="signup">
		<div class="content">
			<h2 style="font-size: 24px;">自定义您的个人头像<img src="../images/green.png"></h2>
			<p class="description">支持*.png;*.gif;*.jpg;*.bmp;*.jpeg格式的图片文件</p>
			<div class="input-groups">
				<div class="top-part">
					<img src="<%=basePath %>${sessionScope.loginUser.photoSticker }" title="${sessionScope.loginUser.userName}" width="120" height="120"/>
					<div class="input-url">
						<img src="<%=basePath %>images/loadingshare.gif" style="display: none;" id="loading"/>
						<input type="file" id="up" name="up" />
						<input type="hidden" name="user.id" id="userId" value="${sessionScope.loginUser.id }">
						<input type="hidden" name="user.album" id="userAblum" value="${sessionScope.loginUser.album }">
					</div>
					<div class="input-save">
						<input type="button" id="uploadBtn" onclick="javascript:$('#up').uploadifyUpload();" value="上传" />
						<input type="button" id="save" value="保存" />
					</div>
				</div>
				<div id="big"><img src="" alt="" width="300" height="300"/></div>
				<div class="right-part">
					<div id="small"></div>
					<div id="medium"></div>
				</div>
			</div>
		</div>
	</form>
	<div class="footer">
		<div class="footer-content">
			<p>Copyright 2012 Sharelife.  All rights reserved.  |   <a href="#">Privacy policy</a>  |   <a href="#">Terms of use</a>  |   <a href="#">Site map</a></p>
		</div>
	</div>
</c:if>
</body>
</html>